const Sequelize = require('sequelize');
const host = 'sh-cynosdbmysql-grp-ant4drn6.sql.tencentcdb.com';
const port = 29706;
// const host = "localhost";
// const port = 3306;
// Yanbaiadmin888
const db = new Sequelize('bank', 'root', 'Bank12345678', {
    host,
    port,
    dialect: 'mysql',
    pool: {
        max: 20,
        min: 0,
        idle: 10000
    },
    timezone: '+08:00',
    dialectOptions: {
        dateStrings: true,
        typeCast: true
    },
    define: {
        // freezeTableName: true,   //自定义表名，不设置会自动将表名转为复数形式
        timestamps: true //自动生成更新时间、创建时间字段：updatedAt,createdAt
    }
})

db.authenticate().then(() => {
    console.log('mysql连接成功');
}).catch(err => {
    console.log('mysql连接失败：' + err);
})

module.exports = db